package com.henry.imkit.network

import android.webkit.WebSettings
import com.henry.imkit.IMKit
import okhttp3.Interceptor
import okhttp3.Response

class HeaderInterceptor : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {

        val request = chain.request()
        val builder = request.newBuilder()

        builder.addHeader("Content-type", "application/json; charset=utf-8")
            .removeHeader("User-Agent") // 移除旧的
            .addHeader("User-Agent", WebSettings.getDefaultUserAgent(IMKit.instance.context)) //添加真正的头部

        return chain.proceed(builder.build())

    }

}